package com.example.gulimallware.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.common.utils.R;
import com.example.gulimallware.service.WmsWareInfoService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import java.util.Objects;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.common.utils.PageUtils;
import com.example.common.utils.Query;

import com.example.gulimallware.dao.WmsWareInfoDao;
import com.example.gulimallware.entity.WmsWareInfoEntity;



@Service("wmsWareInfoService")
public class WmsWareInfoServiceImpl extends ServiceImpl<WmsWareInfoDao, WmsWareInfoEntity> implements WmsWareInfoService {



    @Override
    public R selectList(Map<String, Object> params) {
        if(Objects.isNull(params.get("key"))){
            params.put("key", "");
        }
        IPage<WmsWareInfoEntity> page = page(new Query<WmsWareInfoEntity>().getPage(params),
                new LambdaQueryWrapper<WmsWareInfoEntity>()
                        .and(StringUtils.isNotBlank(params.get("key").toString()),
                                w -> w.likeRight(WmsWareInfoEntity::getName, params.get("key"))
                                        .or().likeRight(WmsWareInfoEntity::getAddress, params.get("key"))
                                        .or().likeRight(WmsWareInfoEntity::getAreacode, params.get("key"))
                        )
        );
        return R.ok().put("page", new PageUtils(page));
    }

}